package com.ext.aic.fragment;

import android.os.Bundle;
import android.view.View;

import androidx.fragment.app.Fragment;

import com.ext.aic.events.OnBundleListener;
import com.ext.aic.handler.BundleHandler;

import java.io.Serializable;

public class BaseFragment extends Fragment implements OnBundleListener {

    private BundleHandler bundleHandler = new BundleHandler();
    private Bundle bundle;

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        bundle = bundleHandler.initBundle(this);
    }

    @Override
    public String getBundleString(String key) {
        return bundleHandler.getBundleString(bundle, key);
    }

    @Override
    public int getBundleInt(String key) {
        return bundleHandler.getBundleInt(bundle, key);
    }

    @Override
    public long getBundleLong(String key) {
        return bundleHandler.getBundleLong(bundle, key);
    }

    @Override
    public boolean getBundleBoolean(String key) {
        return bundleHandler.getBundleBoolean(bundle, key);
    }

    @Override
    public <T extends Serializable> T getSerializable(String key, Class<T> clazz) {
        return bundleHandler.getSerializable(bundle, key, clazz);
    }
}
